home *** CD-ROM | disk | FTP | other *** search
- #!./bash
- # How to make a distribution tarfile.
- #
- # $1 is the name of the program.
- # $2 is the version number.
- # Remaining args are files to tar.
-
- PROGRAM=$1
- VERSION=$2
-
- shift; shift
-
- if [ "$PROGRAM" = "" -o "$VERSION" = "" ]; then
- echo "Usage: make-tarfile <progname> <version> <file ...>"
- exit 2;
- fi
-
- TARFILE=$PROGRAM.tar
- TARDIR=$PROGRAM-$VERSION
-
- rm -rf $TARFILE $TARDIR
- mkdir $TARDIR
- topdir=$(pwd)
- where_I_am=$TARDIR
-
- trap "cd $topdir" 3
-
- for i in $*; do
- filename=$i
- while [ "$filename" ]; do
- remainder=$(echo ${filename#*/})
- dir=$(echo $filename | sed "s@$remainder@@" | sed "s@/@@")
- if [ "$dir" ]; then
- if [ ! -d $where_I_am/$dir ]; then mkdir $where_I_am/$dir; fi
- cd $where_I_am/$dir; where_I_am=$(pwd)
- filename=$remainder
- else
- break
- fi
- done
- cd $topdir; where_I_am=$TARDIR
- ln -s $topdir/$i $TARDIR/$i
- done
-
- tar -chf $TARFILE $TARDIR
- rm -rf $TARDIR
-
- exit 0
-